﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class ZmobleManager : MonoBehaviour
{
    public static ZmobleManager instance;
    private List<Zomble> zombles;
    public void AddZomble(Zomble zomble)
    {
        zombles.Add(zomble);
    }
    private void Awake()
    {
        instance = this;
    }
    /// <summary>
    /// 获取最近的僵尸
    /// </summary>
    /// <returns></returns>
    public Zomble GetZombleMin(int lineNum,Vector2 pos)
    {
        Zomble zomble = null;
        float dis = 1000;
        for(int index=0;index<zombles.Count;index++)
        {
            if(zombles[index].currGrid.Point.y==lineNum&&Vector2.Distance(pos,zombles[index].transform.position)<dis)
            {
                zomble = zombles[index];
                dis = Vector2.Distance(pos, zombles[index].transform.position);
            }
        }
        return zomble;
    }
}
